
from tkinter import *
import tkinter.messagebox as msg
top = Tk()

top.title("注册界面")
top.geometry("280x190")
L1 = Label(top, text = "用户名")
L1.place(x = 5, y = 10)
E1 = Entry(top, bd = 5)
E1.place(x = 53, y = 8)
L2 = Label(top, text = "密码",)
L2.place(x = 5, y = 40)
E2 = Entry(top, bd = 5, show = '*')
E2.place(x = 53, y = 38)
L3 = Label(top, text = "邮箱")
L3.place(x = 5, y = 70)
E3 = Entry(top, bd = 5)
E3.place(x = 53, y = 68)
L4 = Label(top, text = "手机号")
L4.place(x = 5, y = 100)
E4 = Entry(top, bd = 5)
E4.place(x = 53, y = 98)
L5 = Label(top, text = "")
L5.place(x = 55, y = 135)
ori = top.cget("background")
users = {}

def submit():
    LL1 = E1.get()
    LL2 = E2.get()
    LL3 = E3.get()
    LL4 = E4.get()
    if LL1 == '' or LL2 == '' or LL3 == '' or LL4 == '':
        L5.config(text = "有项目未填写", bg = 'red')
        top.mainloop()
        return 
    else:
        L5.config(text = "", bg = ori)
        
    
    if LL1 in users:
        msg.showinfo("提示","该用户名已存在，请换一个名字")
    else :
        users[LL1] = [LL2, LL3, LL4]
        print("新注册了一个用户:")
        print("用户名是", LL1)
        print("密码是", LL2)
        print("邮箱是", LL3)
        print("电话号码是", LL4)        
        print(users)
    E1.delete(0,END)
    E2.delete(0,END)
    E3.delete(0,END)
    E4.delete(0,END)
    top.mainloop()
B1 = Button(top, text = "提交", command = submit)
B1.place(x = 53, y = 158)
top.mainloop()